<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\DB;
class AdvertModel extends Model
{
    protected $table='advert';
    // 广告列表model
    protected $primaryKey='id';
    protected $guarded=[];
    public $timestamps=false;

    const IS_YES = 1; // banner图
    const IS_NOT  = 0; // 其他

    public function getType( $key = null )
    {
        $array = [
            self::IS_YES  => 'banner图',
            self::IS_NOT   => '其他'
        ];
        if( $key !== null )
        {
            return array_key_exists($key, $array ) ? $array[$key] : $array[self::IS_NOT];
        }
        return $array;
    }
    public function isShow( $key = null )
    {
       $array = [
            self::IS_YES  => '顯示',
            self::IS_NOT   => '不顯示'
        ];
        if( $key !== null )
        {
            return array_key_exists($key, $array ) ? $array[$key] : $array[self::IS_NOT];
        } 
        return $array;
    }
    
}
